<%@ taglib prefix="maxlength" uri="http://www.springframework.org/tags/form" %>
<%--
  Created by IntelliJ IDEA.
  User: Easy
  Date: 2017-09-27
  Time: 15:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>

<div class="row">
    <div class="col-md-12">

        <form  class="form-horizontal" id="addCameraForm" >
            <div class="panel panel-default">
                <div class="panel-body">

                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label">位置</label>
                                <div class="col-md-9">
                                    <div class="input-group">
                                        <span class="input-group-addon"><span class="fa fa-eye"></span></span>
                                        <input type="text" class="form-control" required name="doorName"  >
                                    </div>
                                    <span class="help-block">请输入摄像头的位置(例如：南门)</span>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-3 control-label">类型</label>
                                <div class="col-md-9">
                                    <div class="input-group">
                                        <span class="input-group-addon"><span class="fa fa-sort"></span></span>
                                        <select class="form-control" name="status" id="status">
                                            <option value="1" selected>进门拍照</option>
                                            <option value="2" >出门拍照</option>
                                        </select>
                                    </div>
                                    <span class="help-block">请选择摄像头的拍照类型</span>
                                </div>
                            </div>
                        </div>


                        <div class="col-md-6">

                            <div class="form-group">
                                <label class="col-md-3 control-label">停车场</label>
                                <div class="col-md-9">
                                    <div class="input-group">
                                        <span class="input-group-addon"><span class="fa fa-eye"></span></span>
                                        <select class="form-control" required id="parkingId" name="parkingId">
                                            <c:forEach items="${parkingList}" var="item">
                                                <option value="${item.id}">${item.name}</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                    <span class="help-block">请选择所属停车场</span>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-3 control-label">设备编号</label>
                                <div class="col-md-9">
                                    <div class="input-group">
                                        <span class="input-group-addon"><span class="fa fa-eye"></span></span>
                                        <input type="text" class="form-control" required name="equip"  >
                                    </div>
                                    <span class="help-block">请输入设备的编号</span>
                                </div>
                            </div>

                        </div>

                    </div>

                </div>
                <div class="panel-footer">
                    <button class="btn btn-default">清除</button>
                    <input type="button"class="btn btn-primary" onclick="save()" value="保存">
                </div>
            </div>
        </form>

    </div>
</div>
<script>
    function save() {
        var param = serializeForm("addCameraForm");
        var parkingId=$('#parkingId option:selected') .val();
        var status=$('#status option:selected') .val();
           $.ajax({
            type: 'post',
            dataType: 'json',
            data: param +"&parkingId=" + parkingId+"&status=" + status,
            async: true,
            url: '/car/camera/saveData',
            success: function (data) {
                if (data.success){
                    layer.msg(data.msg,{icon:1,time:1000},function () {
                       layer.close(top.layer_cameraAdd);
                       reloadPage();
                    });
                }else{
                    layer.msg(data.msg,{icon: 2,time:1000});
                }
            },
            error: function () {
                alert("保存未成功")
            }
        })
    }

</script>
